package com.sumainfor.zuul.controller;

import com.sumainfor.common.util.JsonResult;
import com.sumainfor.zuul.service.ZfeignService;
import com.sumainfor.zuul.service.ZxZuulService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 功能描述:其他部门调用网关的控制器
 */
@RestController
@RequestMapping("/provider/Zfeign")
public class ZfeignController {

    @Autowired
    private ZfeignService zfeignService;
    @Autowired
    private ZxZuulService zxZuulService;

    /**
     * 根据服务管家的员工编号查询服务管家的姓名
     *
     * @return
     */
    @GetMapping("/getButlerName")
    public JsonResult getButlerName(@RequestParam List<String> idList) {
        System.out.println("idlist:" + idList);
        JsonResult result = new JsonResult();
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("idList", idList);
        List<Map<String, Object>> list = zfeignService.getButlerName(params);
        if (list != null) {
            result.put(list);
        } else {
            result.putFailed("服务器繁忙");
        }
        return result;
    }

    /**
     * 根据员工编号获取员工姓名
     *
     * @return
     */
    @PostMapping("/getDeptNameByDeptId")
    public JsonResult getDeptNameByDeptId(@RequestBody List<String> idList) {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("idList", idList);
        JsonResult result = new JsonResult();
        List<Map<String, Object>> list = zfeignService.getDeptNameByDeptId(params);
        if (list != null) {
            result.put(list);
        } else {
            result.putFailed("服务器繁忙");
        }
        return result;
    }

    /**
     * 房源上架详情查询房源的收房专员、归属服务中心、服务管家
     *
     * @return
     */
    @PostMapping("/getHousingInfoName")
    public Map<String, Object> getHousingInfoName(@RequestBody Map<String, Object> params) {
        System.out.println("params:===================" + params);
        return zfeignService.getHousingInfoName(params);
    }

    /**
     * 市场部经理房源定价列表查询服务中心和定价人信息
     *
     * @return
     */
    @PostMapping("/getHousingInfoNameFd")
    public Map<String, Object> getHousingInfoNameFd(@RequestBody Map<String, Object> params) {
        return zfeignService.getHousingInfoNameFd(params);
    }

    /**
     * 根据员工编号查询员工的姓名
     *
     * @return
     */
    @GetMapping("/getUserName")
    public JsonResult getUserName(@RequestParam Map<String, Object> params) {
        JsonResult result = new JsonResult();

        Map<String, Object> map = zfeignService.getUserName(params);
        if (map != null) {
            result.put(map);
        } else {
            result.putFailed("服务器繁忙");
        }
        return result;
    }

    /**
     * 签约时，获取输入房源编号的归属管家和归属中心
     */
    @GetMapping("/getUserDeptName")
    public JsonResult getUserDeptName(@RequestParam Map<String, Object> params) {
        JsonResult result = new JsonResult();

        Map<String, Object> map = zfeignService.getUserDeptName(params);
        if (map != null) {
            result.put(map);
        } else {
            result.putFailed("服务器繁忙");
        }
        return result;
    }

    /**
     * 转单池的查询转单人的信息
     */
    @PostMapping("/getPuserListById")
    public JsonResult getPuserListById(@RequestBody Map<String, Object> params) {
        JsonResult result = new JsonResult();
        List<Map<String, Object>> list = zfeignService.getPuserListById(params);
        if (list != null) {
            result.put(list);
        } else {
            result.putFailed("服务器繁忙");
        }
        return result;
    }

    /**
     * 运营部服务秘书账单管理根据编号查询管家的姓名
     */
    @PostMapping("/getSysUserBySysUserId")
    public JsonResult getSysUserBySysUserId(@RequestBody Map<String, Object> params) {
        JsonResult result = new JsonResult();
        System.out.println("网关接收到的参数:" + params);
        Map<String, Object> map = zfeignService.getSysUserBySysUserId(params);
        if (map != null) {
            result.put(map);
        } else {
            result.putFailed("服务器繁忙");
        }
        return result;
    }

    /**
     * 租后主管查询报修人的信息
     *
     * @return
     */
    @PostMapping("/getRepairUserList")
    public JsonResult getRepairUserList(@RequestBody Map<String, Object> params) {
        System.out.println("网关接收到的params:" + params);
        JsonResult result = new JsonResult();
        Map<String, Object> map = zfeignService.getRepairUserList(params);
        if (map != null) {
            result.put(map);
        } else {
            result.putFailed("服务器繁忙");
        }
        return result;
    }

    /**
     * 查询运营部服务秘书的姓名列表
     *
     * @return
     */
    @PostMapping("/getWegNameList")
    public JsonResult getWegNameList(@RequestBody Map<String, Object> params) {
        System.out.println("params:" + params);
        JsonResult result = new JsonResult();
        List<Map<String, Object>> list = zfeignService.getButlerName(params);
        if (list != null) {
            result.put(list);
        } else {
            result.putFailed("服务器繁忙");
        }
        return result;
    }

    /**
     * 根据服务管家的员工编号查询服务管家的姓名
     *
     * @return
     */
    @PostMapping("/getRuserList")
    public JsonResult getRuserList(@RequestBody Map<String, Object> params) {
        System.out.println("维修师傅网关接收的奥迪值：" + params);
        JsonResult result = new JsonResult();
        Map<String, Object> map = zfeignService.getRuserList(params);
        if (map != null) {
            result.put(map);
        } else {
            result.putFailed("服务器繁忙");
        }
        return result;
    }

    /*维修师傅查询房源归属人的信息*/
    @PostMapping("/getReapirSysUser")
    public JsonResult getReapirSysUser(@RequestBody Map<String, Object> params) {
        System.out.println("维修师傅 接收到的值：" + params);
        JsonResult result = new JsonResult();
        List<Map<String, Object>> list = zfeignService.getReapirSysUser(params);
        if (list != null) {
            result.put(list);
        } else {
            result.putFailed("服务器繁忙");
        }
        return result;
    }

    /**
     * 租后主管管理人员查询服务秘书和服务管家
     */
    @PostMapping("/getDiUserIdList")
    public JsonResult getDiUserIdList(@RequestBody Map<String, Object> params) {
        System.out.println("维修师傅 接收到的值：" + params);
        JsonResult result = new JsonResult();
        List<Map<String, Object>> list = zfeignService.getDiUserIdList(params);
        if (list != null) {
            result.put(list);
        } else {
            result.putFailed("服务器繁忙");
        }
        return result;
    }

    /**
     * 服务管家根据公司编号查询公司所在的市编号
     */
    @PostMapping("/getSysAreaList")
    public JsonResult getSysAreaList(@RequestBody Map<String, Object> params) {
        System.out.println("维修师傅 接收到的值：" + params);
        JsonResult result = new JsonResult();
        List<Map<String, Object>> list = zfeignService.getSysAreaList(params);
        if (list != null) {
            result.put(list);
        } else {
            result.putFailed("服务器繁忙");
        }
        return result;
    }

    /**
     * 服务管家根据公司编号查询公司所在的市编号
     */
    @PostMapping("/getUsrList")
    public JsonResult getUsrList(@RequestBody Map<String, Object> params) {
        System.out.println("getUsrList网关接收到的参数：" + params);
        JsonResult result = new JsonResult();
        List<Map<String, Object>> list = zfeignService.getUsrList(params);
        if (list != null) {
            result.put(list);
        } else {
            result.putFailed("服务器繁忙");
        }
        return result;
    }

    /**
     * 查询服务中心下的全部角色列表
     */
    @GetMapping("/getWoUserIdList")
    public JsonResult getWoUserIdList(@RequestParam Map<String, Object> params) {
        System.out.println("getUsrList网关接收到的参数：" + params);
        JsonResult result = new JsonResult();
        List<Map<String, Object>> list = zfeignService.getWoUserIdList(params);
        if (list != null) {
            result.put(list);
        } else {
            result.putFailed("服务器繁忙");
        }
        return result;
    }

    /**
     * 查询服务中心下的全部角色列表
     */
    @GetMapping("/getWoSaleIdList")
    public JsonResult getWoSaleIdList(@RequestParam Map<String, Object> params) {
        return zfeignService.getWoSaleIdList(params);
    }
    /**
     *  租后主管根据员工编号查询员工的信息
     */
    @GetMapping("/getUserInfo")
    public JsonResult getUserInfo(@RequestParam Map<String,Object> params){
        JsonResult result=new JsonResult();
        Map<String,Object> map=zfeignService.getUserInfo(params);
        if(map!=null){
            result.put(map);
        }else{
            result.putFailed("服务器繁忙");
        }
        return result;
    }
    /**
     *  服务管家查询受理人信息
     */
    @PostMapping("/getRepairOuserList")
    public JsonResult getRepairOuserList(@RequestBody Map<String,Object> params){
        JsonResult result=new JsonResult();
        List<Map<String,Object>> list=zfeignService.getRepairOuserList(params);
        if(list!=null){
            result.put(list);
        }else{
            result.putFailed("服务器繁忙");
        }
        return result;
    }
    /**
     * 查询所有服务中心
     * @return
     */
    @GetMapping("/getDeptListByType")
    public JsonResult getDeptListByType(@RequestParam Map<String,Object> params){
        JsonResult result=new JsonResult();
        List<Map<String,Object>> list=zxZuulService.getDeptListByType(params);
        if(list!=null){
            result.put(list);
        }else{
            result.putFailed("服务器繁忙");
        }
        return result;
    }
    /**
     * 新增消息提醒
     */
    @PostMapping("/addMessage")
    public JsonResult addMessage(@RequestBody Map<String,Object> params){
        return zfeignService.addMessage(params);
    }

    /**
     * 查询所有服务中心
     * @return
     */
    @GetMapping("/getSysDeptInfoList")
    public JsonResult getSysDeptInfoList(){
        return zfeignService.getSysDeptInfoList();
    }
    /**
     * 租后主管查询员工信息 （服务管家和服务秘书）
     * @return
     */
    @GetMapping("/getSysDeptRoleList")
    public JsonResult getSysDeptRoleList(@RequestParam Map<String,Object> params){

        return zfeignService.getSysDeptRoleList(params);
    }
    /**
     * 根据公司编号查询公司所在的市编号
     * @return
     */
    @GetMapping("/getTransferInfoList")
    public JsonResult getTransferInfoList(@RequestParam Map<String,Object> params){
        JsonResult result=new JsonResult();
        List<Map<String,Object>> list=zxZuulService.getTransferInfoList(params);
        if(list!=null){
            result.put(list);
        }else{
            result.putFailed("服务器繁忙");
        }
        return result;
    }
    /**
     * 服务秘书审核账单查询账单的支付账号信息
     */
    @PostMapping("/getTranInfoList")
    public JsonResult getTranInfoList(@RequestBody Map<String, Object> params) {
        return  zfeignService.getTranInfoList(params);
    }
}
